import firedrake
/home/firedrake/firedrake/lib/python3.10/site-packages/pytools/__init__.py:2428: UserWarning: unable to find git revision
warn("unable to find git revision")
/home/firedrake/firedrake/src/loopy/loopy/schedule/__init__.py:2201: UserWarning: pytools.persistent_dict 'loopy-schedule-cache-v4-2024.1-islpy2024.1-cgen2020.1-967461ba9c3677ee6f0334b9ee95ef0f0e51d208-v1': enabling safe_sync as default. This provides strong protection against data loss, but can be unnecessarily expensive for use cases such as caches.Pass 'safe_sync=False' if occasional data loss is tolerable. Pass 'safe_sync=True' to suppress this warning.
schedule_cache = WriteOncePersistentDict(
/home/firedrake/firedrake/src/loopy/loopy/tools.py:914: UserWarning: pytools.persistent_dict 'loopy-memoize-cache-buffer_array-LoopyKeyBuilder.LoopyKeyBuilder-v0-2024.1-islpy2024.1-cgen2020.1-967461ba9c3677ee6f0334b9ee95ef0f0e51d208-v1': enabling safe_sync as default. This provides strong protection against data loss, but can be unnecessarily expensive for use cases such as caches.Pass 'safe_sync=False' if occasional data loss is tolerable. Pass 'safe_sync=True' to suppress this warning.
transform_cache = WriteOncePersistentDict(
/home/firedrake/firedrake/src/loopy/loopy/tools.py:914: UserWarning: pytools.persistent_dict 'loopy-memoize-cache-preprocess_program-LoopyKeyBuilder.LoopyKeyBuilder-v0-2024.1-islpy2024.1-cgen2020.1-967461ba9c3677ee6f0334b9ee95ef0f0e51d208-v1': enabling safe_sync as default. This provides strong protection against data loss, but can be unnecessarily expensive for use cases such as caches.Pass 'safe_sync=False' if occasional data loss is tolerable. Pass 'safe_sync=True' to suppress this warning.
transform_cache = WriteOncePersistentDict(
/home/firedrake/firedrake/src/loopy/loopy/codegen/__init__.py:313: UserWarning: pytools.persistent_dict 'loopy-code-gen-cache-v3-2024.1-islpy2024.1-cgen2020.1-967461ba9c3677ee6f0334b9ee95ef0f0e51d208-v1': enabling safe_sync as default. This provides strong protection against data loss, but can be unnecessarily expensive for use cases such as caches.Pass 'safe_sync=False' if occasional data loss is tolerable. Pass 'safe_sync=True' to suppress this warning.
code_gen_cache = WriteOncePersistentDict(
/home/firedrake/firedrake/src/loopy/loopy/target/execution.py:724: UserWarning: pytools.persistent_dict 'loopy-typed-and-scheduled-cache-v1-2024.1-islpy2024.1-cgen2020.1-967461ba9c3677ee6f0334b9ee95ef0f0e51d208-v1': enabling safe_sync as default. This provides strong protection against data loss, but can be unnecessarily expensive for use cases such as caches.Pass 'safe_sync=False' if occasional data loss is tolerable. Pass 'safe_sync=True' to suppress this warning.
typed_and_scheduled_cache = WriteOncePersistentDict(
/home/firedrake/firedrake/src/loopy/loopy/target/execution.py:732: UserWarning: pytools.persistent_dict 'loopy-invoker-cache-v10-2024.1-islpy2024.1-cgen2020.1-967461ba9c3677ee6f0334b9ee95ef0f0e51d208-v1': enabling safe_sync as default. This provides strong protection against data loss, but can be unnecessarily expensive for use cases such as caches.Pass 'safe_sync=False' if occasional data loss is tolerable. Pass 'safe_sync=True' to suppress this warning.
invoker_cache = WriteOncePersistentDict(
import viskex
import common_firedrake as common # isort: skip
Generate meshes of the unit cube by dividing each edge of the cube in 6 segments, using either a tetrahedral or hexahedral mesh.
cube_tetra = firedrake.UnitCubeMesh(6, 6, 6, hexahedral=False)
cube_hexa = firedrake.UnitCubeMesh(6, 6, 6, hexahedral=True)
Mark boundaries according to the $(x, y, z)$ position of the vertices of the mesh:
cube_tetra_with_boundaries = common.mark_boundaries(cube_tetra)
cube_hexa_with_boundaries = common.mark_boundaries(cube_hexa)
We plot the resulting boundaries.
viskex.firedrake.plot_mesh_sets(cube_tetra_with_boundaries, 2, "boundaries")
viskex.firedrake.plot_mesh_sets(cube_hexa_with_boundaries, 2, "boundaries")
We can also plot all boundaries which belong to the mesh set $4$ (first and second plot), $2$ (third and fourth plot) or both (fifth and sixth plot), which will be displayed with colors. The rest of the mesh facets are still included in the plot, but are colored in gray.
viskex.firedrake.plot_mesh_sets(
cube_tetra_with_boundaries, 2, "boundaries_4", viskex.utils.values_in([4]))
viskex.firedrake.plot_mesh_sets(
cube_hexa_with_boundaries, 2, "boundaries_4", viskex.utils.values_in([4]))
viskex.firedrake.plot_mesh_sets(
cube_tetra_with_boundaries, 2, "boundaries_2", viskex.utils.values_in([2]))
viskex.firedrake.plot_mesh_sets(
cube_hexa_with_boundaries, 2, "boundaries_2", viskex.utils.values_in([2]))
viskex.firedrake.plot_mesh_sets(
cube_tetra_with_boundaries, 2, "boundaries_24", viskex.utils.values_in([2, 4]))
viskex.firedrake.plot_mesh_sets(
cube_hexa_with_boundaries, 2, "boundaries_24", viskex.utils.values_in([2, 4]))
The mesh sets are stored as part of the firedrake mesh object. If the mesh sets get removed, all cells will be displayed in gray in the plot.
cube_tetra.topology_dm.removeLabel(firedrake.cython.dmcommon.FACE_SETS_LABEL)
cube_hexa.topology_dm.removeLabel(firedrake.cython.dmcommon.FACE_SETS_LABEL)
viskex.firedrake.plot_mesh_sets(cube_tetra, 2, "boundaries")
/home/firedrake/firedrake/lib/python3.10/site-packages/pyvista/plotting/mapper.py:670: RuntimeWarning: All-NaN axis encountered clim = [np.nanmin(scalars), np.nanmax(scalars)]
viskex.firedrake.plot_mesh_sets(cube_hexa, 2, "boundaries")
/home/firedrake/firedrake/lib/python3.10/site-packages/pyvista/plotting/mapper.py:670: RuntimeWarning: All-NaN axis encountered clim = [np.nanmin(scalars), np.nanmax(scalars)]